import Vue from 'vue'
import Vuex from 'vuex'
// import getters from './getters'
import app from './modules/app'
import settings from './modules/settings'
import user from './modules/user'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    tomCount: 8
  },
  mutations: {
    addTom(state, data) {
      state.tomCount += data
    }
  },
  actions: {
    // context等效于this.$store
    addTomSync(context, data) {
      setTimeout(() => {
        context.commit('addTom', data)
      }, 2000)
    }
  },
  // 相当于computed计算属性
  // getters: {
  //   showTomCount(state) {
  //     return 'tom' + state.tomCount
  //   }
  // },
  getters: {},
  modules: {
    app,
    settings,
    user
  }

})

export default store
